package genetic;

import java.util.ArrayList;
import java.util.HashMap;

import org.jfree.data.xy.XYSeriesCollection;

public class DataSet extends HashMap<String, Double> {

	
	public static ArrayList<DataSet> createListFromXYSeriesCollection(XYSeriesCollection coll) {
		ArrayList<DataSet> list = new ArrayList<DataSet>();
		
		// minimale Laenge finden
		int len = coll.getItemCount(0);
		if (coll.getSeriesCount() >= 2) {
			for (int i=0; i<coll.getSeriesCount(); i++) {
				if (coll.getItemCount(i) < len)
					len = coll.getItemCount(i);
			}
		}
		
		// DataSets generieren bis minimale Laenge
		for (int i=0; i<len; i++) {
			DataSet ds = new DataSet();
			for (int j=0; j<coll.getSeriesCount(); j++) {
				ds.put((String)coll.getSeriesKey(j), coll.getYValue(j, i));
			}
			list.add(ds);
		}
		
		return list;
	}
}
